#include "TaskManager.h"

TaskManager::TaskManager()
{

}

MU_RETURNS TaskManager::stopATasks(UC2 data)
{
    for(int i=0;i<16;i++){
       if(( data >> i ) & 0x01){
           stopATask(MU_TASK_INDEX(0x01 << i));
       }
    }
    return MU_RETURN_SUCCESS;
}



MU_RETURNS TaskManager::stopATask(MU_TASK_INDEX index)
{
    bool ret = false;
    switch (index) {
    case MU_TASK_INDEX_CAM:
        if(getProcess(0)){

        }
        break;
    case MU_TASK_INDEX_PLC:
        break;
    case MU_TASK_INDEX_WELD:
        break;
    case MU_TASK_INDEX_LOG:
        break;
    case MU_TASK_INDEX_SQL:
        break;
    case MU_TASK_INDEX_IO:
        break;
    case MU_TASK_INDEX_MACHINE:
        break;
    case MU_TASK_INDEX_LASYER:
        break;
    case MU_TASK_INDEX_CALC:
        break;
    case MU_TASK_INDEX_IMAGE:
        break;
    case MU_TASK_INDEX_ROBOT:
        break;
    default:
        break;
    }
//    try {

//    } catch () {

//    }
    return setATask(index,ret);
}

MU_RETURNS TaskManager::setATask(MU_TASK_INDEX index, bool suc)
{
    if(suc){
        currentStatus.run_Process |= index;
        return MU_RETURN_SUCCESS;
    }else{
        currentStatus.run_Process &= (~index);
        return MU_RETURN_SUCCESS;
    }
}

